IdeaBlade.EntityModel.Compat Assembly > IdeaBlade.EntityModel Namespace > Coroutine Class > Start Method : Start(IEnumerable<Func<INotifyCompleted>>,Action<CoroutineOperation>) Method |
'Declaration
Public Overloads Shared Function Start( _ ByVal asyncFns As IEnumerable(Of Func(Of INotifyCompleted)), _ Optional ByVal completedHandler As Action(Of CoroutineOperation) _ ) As CoroutineOperation
'Usage
Dim asyncFns As IEnumerable(Of Func(Of INotifyCompleted)) Dim completedHandler As Action(Of CoroutineOperation) Dim value As CoroutineOperation value = Coroutine.Start(asyncFns, completedHandler)
public static CoroutineOperation Start( IEnumerable<Func<INotifyCompleted>> asyncFns, Action<CoroutineOperation> completedHandler )
This overload of the Start method is useful in Visual Basic, where iterators are not supported.
public void CoroutineSample3() { Coroutine.Start(Sample3Actions(_entityManager), (op) => { MessageBox.Show(op.Result.ToString()); }); } private IEnumerable<Func<INotifyCompleted>> Sample3Actions(DomainModelEntityManager mgr) { // Not an iterator block - this returns a list of async actions yield return () => mgr.Customers.ExecuteAsync(); yield return () => mgr.Employees.ExecuteAsync(); yield return () => Coroutine.Return("all done"); }
Public Sub CoroutineSample3() Coroutine.Start(Sample3Actions(Manager), Sub(op As CoroutineOperation) MessageBox.Show(op.Result.ToString()) End Sub) End Sub Private Function Sample3Actions(ByVal mgr As NorthwindIBEntities) As IEnumerable(Of Func(Of INotifyCompleted)) ' Setup of the list of async functions for the Coroutine to execute serially. Dim operationList = New List(Of Func(Of INotifyCompleted)) Dim f1 As Func(Of INotifyCompleted) = Function() mgr.Customers.ExecuteAsync() operationList.Add(f1) Dim f2 As Func(Of INotifyCompleted) = Function() mgr.Employees.ExecuteAsync() operationList.Add(f2) Dim f3 As Func(Of INotifyCompleted) = Function() Coroutine.Return("all done") operationList.Add(f3) Return operationList End Function
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2